package com.hmall.api.client;

import com.hmall.api.client.fallback.ItemClientFallback;
import com.hmall.api.config.DefaultFeignConfig;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


/**
 * 商品微服务的远程调用的feign接口
 */
@FeignClient(value = "item-service",
            configuration = DefaultFeignConfig.class,
            fallbackFactory = ItemClientFallback.class)     //仅对当前的FeignCLient日志配置生效

public interface ItemClient {
    /**
     * 定义查询的方法
     */
    @GetMapping("/items")
    public List<ItemDTO> queryItemByIds(@RequestParam("ids") List<Long> ids);
/**
 * 库存
 */
@ApiOperation("批量扣减库存")
@PutMapping("/items/stock/deduct")
public void deductStock(@RequestBody List<OrderDetailDTO> items);
}
